package com.example.coreshopapp.weight;

import android.app.Activity;
import android.app.Dialog;
import android.view.Gravity;
import android.view.KeyEvent;
import android.widget.TextView;

import com.example.coreshopapp.R;

public class CustomProgressDialog extends Dialog {
    public CustomProgressDialog(Activity context, int theme) {
        super(context, theme);
        setContentView(R.layout.dialog_custom_progress);
        getWindow().getAttributes().gravity = Gravity.CENTER;
        setCancelable(false);

    }

    /**
     *
     * [Summary] setTitile 标题
     *
     *
     */
    public CustomProgressDialog setTitile(String strTitle) {
        return this;
    }

    /**
     *
     * [Summary] setMessage 提示内容
     *
     *
     */
    public CustomProgressDialog setMessage(String strMessage) {
        TextView tvMsg = (TextView)findViewById(R.id.load_info_text);

        if (tvMsg != null) {
            tvMsg.setText(strMessage);
        }

        return this;
    }

    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        if (event.getKeyCode() == KeyEvent.KEYCODE_BACK)
            dismiss();
        return super.onKeyDown(keyCode, event);
    }

}
